package com.fr.report.cellElement;

import com.fr.base.FCloneable;
import com.fr.base.Style;
import com.fr.base.core.BaseCoreUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.highlight.HighlightGroup;
import com.fr.report.js.NameJavaScriptGroup;
import com.fr.report.web.ui.Widget;
import java.awt.Rectangle;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;

public class CoverCellElement
  implements CellElement
{
  private static final Object NULL = new Object();
  private static final CellPageAttr C_NULL = new CellPageAttr();
  private CellElement cell;
  private int row;
  private int column;
  private int rowspan;
  private int columnspan;
  private Object value;
  private CellPageAttr cellPageAttr;
  private PaintInfo info;
  private Map attributes;

  public CoverCellElement(CellElement paramCellElement, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    this.value = NULL;
    this.cellPageAttr = C_NULL;
    this.info = null;
    this.attributes = null;
    this.cell = paramCellElement;
    if (this.cell == null)
      throw new NullPointerException("Covered cell can not be null");
    this.column = paramInt1;
    this.row = paramInt2;
    this.columnspan = paramInt3;
    this.rowspan = paramInt4;
  }

  public CoverCellElement(CellElement paramCellElement, int paramInt1, int paramInt2, int paramInt3, int paramInt4, Object paramObject)
  {
    this(paramCellElement, paramInt1, paramInt2, paramInt3, paramInt4);
    this.value = paramObject;
  }

  public CellElement clone(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    throws CloneNotSupportedException
  {
    CoverCellElement localCoverCellElement = (CoverCellElement)clone();
    localCoverCellElement.setColumn(paramInt1);
    localCoverCellElement.setRow(paramInt2);
    localCoverCellElement.setColumnSpan(paramInt3);
    localCoverCellElement.setRowSpan(paramInt4);
    return localCoverCellElement;
  }

  public void setCellPaintInfo(Rectangle paramRectangle1, Rectangle paramRectangle2, Object paramObject)
  {
    this.info = new PaintInfo(paramRectangle1, paramRectangle2, paramObject, null);
  }

  public Rectangle getCellPaintRect()
  {
    return ((this.info == null) ? null : PaintInfo.access$100(this.info));
  }

  public Rectangle getCellClipRect()
  {
    return ((this.info == null) ? null : PaintInfo.access$200(this.info));
  }

  public Object getCellOriValue()
  {
    return ((this.info == null) ? null : PaintInfo.access$300(this.info));
  }

  public CellElement deriveCellElement(int paramInt1, int paramInt2)
  {
    return new CoverCellElement(this.cell, paramInt1, paramInt2, this.columnspan, this.rowspan, this.value);
  }

  public CellElement deriveCellElement(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    return new CoverCellElement(this.cell, paramInt1, paramInt2, paramInt3, paramInt4, this.value);
  }

  public int getColumn()
  {
    return this.column;
  }

  public int getColumnSpan()
  {
    return this.columnspan;
  }

  public int getRow()
  {
    return this.row;
  }

  public int getRowSpan()
  {
    return this.rowspan;
  }

  public void setColumn(int paramInt)
  {
    this.column = paramInt;
  }

  public void setColumnSpan(int paramInt)
  {
    this.columnspan = paramInt;
  }

  public void setRow(int paramInt)
  {
    this.row = paramInt;
  }

  public void setRowSpan(int paramInt)
  {
    this.rowspan = paramInt;
  }

  public Iterator attributeKeyIterator()
  {
    if (this.attributes == null)
      return this.cell.attributeKeyIterator();
    HashSet localHashSet = new HashSet();
    Iterator localIterator = this.cell.attributeKeyIterator();
    while (localIterator.hasNext())
      localHashSet.add(localIterator.next());
    localHashSet.addAll(this.attributes.keySet());
    return localHashSet.iterator();
  }

  public Object getAttribute(Object paramObject)
  {
    Object localObject = (this.attributes == null) ? null : this.attributes.get(paramObject);
    return ((localObject == null) ? this.cell.getAttribute(paramObject) : localObject);
  }

  public CellExpandAttr getCellExpandAttr()
  {
    return this.cell.getCellExpandAttr();
  }

  public CellGUIAttr getCellGUIAttr()
  {
    return this.cell.getCellGUIAttr();
  }

  public CellInsertPolicyAttr getCellInsertPolicyAttr()
  {
    return this.cell.getCellInsertPolicyAttr();
  }

  public CellPageAttr getCellPageAttr()
  {
    return ((this.cellPageAttr != C_NULL) ? this.cellPageAttr : this.cell.getCellPageAttr());
  }

  public HighlightGroup getHighlightGroup()
  {
    return this.cell.getHighlightGroup();
  }

  public NameJavaScriptGroup getNameHyperlinkGroup()
  {
    return this.cell.getNameHyperlinkGroup();
  }

  public Present getPresent()
  {
    return this.cell.getPresent();
  }

  public String getScript()
  {
    return this.cell.getScript();
  }

  public Style getStyle()
  {
    return this.cell.getStyle();
  }

  public Object getValue()
  {
    return ((this.value != NULL) ? this.value : this.cell.getValue());
  }

  public Widget getWidget()
  {
    return this.cell.getWidget();
  }

  public Object removeAttribute(Object paramObject)
  {
    Object localObject = null;
    if ((this.attributes != null) && (paramObject != null))
    {
      localObject = this.attributes.remove(paramObject);
      if (this.attributes.size() == 0)
        this.attributes = null;
    }
    return localObject;
  }

  public void setAttribute(Object paramObject1, Object paramObject2)
  {
    if (paramObject1 == null)
      return;
    if (paramObject2 == null)
    {
      removeAttribute(paramObject1);
      return;
    }
    if (this.attributes == null)
      this.attributes = new HashMap();
    this.attributes.put(paramObject1, paramObject2);
  }

  public void setCellExpandAttr(CellExpandAttr paramCellExpandAttr)
  {
    throw new UnsupportedOperationException();
  }

  public void setCellGUIAttr(CellGUIAttr paramCellGUIAttr)
  {
    throw new UnsupportedOperationException();
  }

  public void setCellInsertPolicyAttr(CellInsertPolicyAttr paramCellInsertPolicyAttr)
  {
    throw new UnsupportedOperationException();
  }

  public void setCellPageAttr(CellPageAttr paramCellPageAttr)
  {
    this.cellPageAttr = paramCellPageAttr;
  }

  public void setHighlightGroup(HighlightGroup paramHighlightGroup)
  {
    throw new UnsupportedOperationException();
  }

  public void setNameHyperlinkGroup(NameJavaScriptGroup paramNameJavaScriptGroup)
  {
    throw new UnsupportedOperationException();
  }

  public void setPresent(Present paramPresent)
  {
    throw new UnsupportedOperationException();
  }

  public void setScript(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public void setStyle(Style paramStyle)
  {
    throw new UnsupportedOperationException();
  }

  public void setValue(Object paramObject)
  {
    this.value = paramObject;
  }

  public void setWidget(Widget paramWidget)
  {
    throw new UnsupportedOperationException();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    throw new UnsupportedOperationException();
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    throw new UnsupportedOperationException();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    CoverCellElement localCoverCellElement = (CoverCellElement)super.clone();
    if ((this.value != NULL) && (this.value != null) && (getValue() instanceof FCloneable))
      localCoverCellElement.setValue(((FCloneable)getValue()).clone());
    if ((this.cellPageAttr != C_NULL) && (this.cellPageAttr != null))
      localCoverCellElement.setCellPageAttr((CellPageAttr)this.cellPageAttr.clone());
    if (this.attributes != null)
      localCoverCellElement.attributes = BaseCoreUtils.cloneMap(this.attributes);
    return localCoverCellElement;
  }

  private static class PaintInfo
  {
    private Rectangle paintInfo;
    private Rectangle clipInfo;
    private Object oriValue;

    private PaintInfo(Rectangle paramRectangle1, Rectangle paramRectangle2, Object paramObject)
    {
      this.paintInfo = paramRectangle1;
      this.clipInfo = paramRectangle2;
      this.oriValue = paramObject;
    }

    PaintInfo(Rectangle paramRectangle1, Rectangle paramRectangle2, Object paramObject, CoverCellElement.1 param1)
    {
      this(paramRectangle1, paramRectangle2, paramObject);
    }

    static Rectangle access$100(PaintInfo paramPaintInfo)
    {
      return paramPaintInfo.paintInfo;
    }

    static Rectangle access$200(PaintInfo paramPaintInfo)
    {
      return paramPaintInfo.clipInfo;
    }

    static Object access$300(PaintInfo paramPaintInfo)
    {
      return paramPaintInfo.oriValue;
    }
  }
}